package red.action;

import com.opensymphony.xwork2.Action;
import red.model.ColumnModel;
import red.service.ColumnService;
import red.service.impl.ColumnServiceImpl;
import red.util.BaseAction;
import red.util.Model;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ColumnAction extends BaseAction {

    private Map<String,Object> result;

    private ColumnService columnService = new ColumnServiceImpl();

    private ColumnModel columnModel;

    private List<ColumnModel> columnModels;

    public ColumnModel getColumnModel() {
        return columnModel;
    }

    public void setColumnModel(ColumnModel columnModel) {
        this.columnModel = columnModel;
    }

    public List<ColumnModel> getColumnModels() {
        return columnModels;
    }

    public void setColumnModels(List<ColumnModel> columnModels) {
        this.columnModels = columnModels;
    }

    public String addcolumn(){
        Model model = getParams();
        columnModel = columnService.addColumn(model);
        return Action.SUCCESS;
    }

    public String deletecolumn(){
        Model model = getParams();
        columnModel = columnService.deleteColumn(model);
        return Action.SUCCESS;
    }

    public String selectcolumn (){
        Model model = getParams();
        columnModels = columnService.selectColumn(model);
        return Action.SUCCESS;
    }

    public String getColumn(){
        columnModels=new ArrayList<>();
        return Action.SUCCESS;
    }
}
